﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Fabrica
{
    public partial class ProduccionJuguetes : Form
    {
        public ProduccionJuguetes()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FabricaEntities entities = new FabricaEntities();
            entities.AddToToyProductions(new ToyProduction
            {
                productionDate = Convert.ToDateTime(textBox3.Text),
                productionId = (from p in entities.ToyProductions
                                select p).Count() + 1,
                quantity = Convert.ToInt32(textBox2.Text),
                toyId = (from t in entities.Toys
                         where Name.Equals(textBox1.Text)
                         select t).FirstOrDefault().toyId
            });
            entities.SaveChanges();
            MessageBox.Show("Produccion de juguete Agregado con exito");
        }
    }
}
